package guda.stark.dal.dao.impl;

import guda.grape.autogen.common.BaseDAO;
import guda.stark.dal.dao.VillageDAO;
import guda.stark.dal.dataobject.VillageDO;
import guda.grape.autogen.common.page.BaseQuery;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class VillageDAOImpl extends BaseDAO implements VillageDAO {

    @Override
	public Long insert(VillageDO village) {
	      try {
                return (Long) getSqlMapperW().insert("village.insert",village);
          } catch (Exception e) {
                throw new RuntimeException(e);
          }

	}

    @Override
	public VillageDO getVillageById(Long villageId) {
	    return (VillageDO)getSqlMapClientTemplate().queryForObject("village.getVillageById", villageId);
	}

    @Override
	public boolean delVillageById(Long villageId) {
	    int num = 0;
        try {
            num = getSqlMapperW().delete("village.delVillageById",villageId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if(num>0){
            return true;
        }else{
            return false;
        }
	}

    @Override
	public List<VillageDO> getVillageByIds(List idsList) {
        Map m = new HashMap();
        m.put("idsList",idsList);
		return getSqlMapClientTemplate().queryForList("village.selectByIds", m);
	}

    @Override
	public void cleanAutoIncrement(Long villageId) {
	    try {
            getSqlMapperW().update("village.cleanAutoIncrement",villageId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
	}

    @Override
    public List<VillageDO> selectForPage(BaseQuery baseQuery) {
        return getSqlMapClientTemplate().queryForList("village.selectForPage", baseQuery);
    }

    @Override
    public int countForPage(BaseQuery baseQuery) {
        return (Integer)getSqlMapClientTemplate().queryForObject("village.countForPage",baseQuery);
    }

    @Override
    public void updateByIdSelective(VillageDO village) {
        try {
            getSqlMapperW().update("village.updateByIdSelective",village);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}

